package com.coldchain ;

import com.coldchain.authclient.interceptor.UserAuthRestInterceptor;
import com.spring4all.swagger.EnableSwagger2Doc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication()
@EnableEurekaClient
@EnableFeignClients(value={"com.coldchain.authclient.feign", "com.coldchain.common.feign"})
@EnableTransactionManagement
@EnableSwagger2
@EnableSwagger2Doc
@EnableScheduling // 开启定时任务
@Controller
public class CysBootstrap {
	public static void main(String[] args) {
		SpringApplication.run(CysBootstrap.class, args);
	}
	
	@Bean
	public UserAuthRestInterceptor userAuthRestInterceptor(){
		return new UserAuthRestInterceptor();
	}

	@GetMapping("/cys/v2/api-docs")
	public String apiDoc(){
		return "redirect:/v2/api-docs";
	}
}
